<?php 
    // Define path to application directory
    defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application/modules/ajf'));
    
    // Define application environment
    defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

    /** Zend_Application */
    set_include_path(implode(PATH_SEPARATOR, array(
        realpath(APPLICATION_PATH . '/../../../lib'),
        get_include_path(),
    )));
    require_once 'Zend/Application.php';

    // Chargement et cumul des application.ini et application-local.ini si ce dernier existe

    $app_ini = array('config' => array());
    $app_ini['config'][] = APPLICATION_PATH . '/configs/' . APPLICATION_ENV . '.ini';
    $app_local_name = APPLICATION_PATH . '/configs/' . APPLICATION_ENV . '-local.ini';

    if(file_exists($app_local_name)) {
        $app_ini['config'][] = $app_local_name;
    }

    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV,
        $app_ini
    );

    try {
        $application->bootstrap()->run();       
    } catch(Exception $e) {
        
        echo $e->getMessage()."<br/><br/>";
        echo "<pre>";
        var_dump($e->getTrace());
        echo "</pre>";
    }